/*
 * MIT License
 *
 * Copyright (c) 2020 wen.gu <454727014@qq.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

/***************************************************************************
 * Name: proxy_types.h
 *
 * Purpose: define service proxy types for implementation CM
 *
 * Developer:
 *   wen.gu , 2020-04-21
 *
 * TODO:
 *
 ***************************************************************************/

#ifndef __ARA_COM_PROXY_TYPES_H__
#define __ARA_COM_PROXY_TYPES_H__
/******************************************************************************
 **    INCLUDES
 ******************************************************************************/
#include <cstdint>
#include <functional>

#include "ara/com/data_types.h"
#include "ara/core/vector.h"

/******************************************************************************
 **    MACROS
 ******************************************************************************/


/******************************************************************************
 **    TYPE DEFINITIONS
 ******************************************************************************/
namespace ara
{
namespace com
{
/******************************************************************************
 **    CLASSES/FUNCTIONS DEFINITIONS
 ******************************************************************************/
struct FindServiceHandle 
{
    //internal::ServiceId service_id;  /** todo, reifneme?? */
    //internal::InstanceId instance_id;
    std::uint32_t uid;

    bool operator==(const FindServiceHandle& other) const
    {
        return (uid == other.uid);
    }
    bool operator<(const FindServiceHandle& other) const
    {
        return (uid < other.uid);
    }
    FindServiceHandle& operator=(const FindServiceHandle& other)
    {
        uid = other.uid;
    }
};

/** for handle type */
class HandleType
{
public:
    HandleType(const ara::com::InstanceIdentifier& id)
        :mInstanceId(id)
    {
        /** todo something */
    }

    HandleType(const HandleType& other)
        :HandleType(other.mInstanceId)
    {
        /** todo something */
    }
    
    HandleType(HandleType&& other) noexcept
        :HandleType(other.mInstanceId)
    {
        /** todo something */
    }

public:
    HandleType& operator=(const HandleType& other)
    {
        mInstanceId = other.mInstanceId;
        return *this;
    }

    HandleType& operator=(HandleType&& other) noexcept
    {
        mInstanceId = other.mInstanceId;
        return *this;
    }
public:
    bool operator==(const HandleType& other) const
    {
        return mInstanceId == other.mInstanceId;
    }

    bool operator<(const HandleType& other) const
    {
        return mInstanceId < other.mInstanceId;
    }

    const ara::com::InstanceIdentifier& GetInstanceId() const
    {
        return mInstanceId;
    }

private:
    ara::com::InstanceIdentifier  mInstanceId;
};


/** Service Handle Container */
template < typename T>
using ServiceHandleContainer = ara::core::Vector<T>;

/** Find service handler */
template < typename T>
using FindServiceHandler = std::function<void(ServiceHandleContainer<T>, FindServiceHandle)>;


} /** namespace com */
} /** namespace ara */

#endif /** !__ARA_COM_PROXY_TYPES_H__ */

